<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});
//注册
Route::get('/register', "\App\Http\Controllers\RegisterController@index");
Route::post('/register', "\App\Http\Controllers\RegisterController@register");//注册行为

//登录退出
Route::get('/login', "\App\Http\Controllers\LoginController@index")->name('login');
Route::post('/login', "\App\Http\Controllers\LoginController@login");//登陆行为
Route::get('/logout', "\App\Http\Controllers\LoginController@logout");

//文章
Route::get('/posts', '\App\Http\Controllers\PostController@index');
Route::get('/posts/create', 'PostController@create');
Route::post('/posts', 'PostController@store');//保存文章
//文章搜索页
Route::get('/posts/search', 'PostController@search');
Route::get('/posts/{post}', 'PostController@show');//使用了绑定模型功能 文章详情页 这是get请求
Route::get('/posts/{post}/edit', 'PostController@edit');
Route::put('/posts/{post}', 'PostController@update');//更新文章 这个是put请求
Route::get('posts/{post}/delete', 'PostController@delete');//删除文章

Route::post('/posts/comment', 'PostController@comment');
Route::get('/posts/{post}/zan', 'PostController@zan');
Route::get('/posts/{post}/unzan', 'PostController@unzan');


//图片上传
Route::post('/posts/image/upload', 'PostController@imageUpload');

// 个人主页
Route::get('/user/{user}', '\App\Http\Controllers\UserController@show');
Route::post('/user/{user}/fan', '\App\Http\Controllers\UserController@fan');
Route::post('/user/{user}/unfan', '\App\Http\Controllers\UserController@unfan');

// 个人设置
Route::get('/user/me/setting', '\App\Http\Controllers\UserController@setting');
Route::post('/user/me/setting', '\App\Http\Controllers\UserController@settingStore');


Auth::routes();
//需要先登录
Route::get('/home', 'HomeController@index')->name('home');
